package querier

import "gorm.io/gen"

type InventoryDimGoods interface {
	// SELECT A.*,B.* FROM wms_goods A left join
	// (
	// SELECT SUM(A.qty*A.mark) sum_qty, A.* FROM wms_inventory A WHERE A.status=1 group by A.goods_id,A.wid
	// ) B ON A.id = B.goods_id
	QueryInentoryByGoodsTotal() (gen.RowsAffected, error)

	// SELECT A.*,B.* FROM wms_goods A left join
	// (
	// SELECT SUM(A.qty*A.mark) sum_qty, A.* FROM wms_inventory A WHERE A.status=1
	// group by A.goods_id,A.wid
	// ) B ON A.id = B.goods_id
	// {{where}}
	// {{if wid > 0}}
	// B.wid=@wid
	// {{end}}
	// {{if goodsId > 0}}
	// AND A.id=@goodsId
	// {{end}}
	// {{end}}
	// LIMIT @start,@pageSize;
	QueryInentoryByGoods(wid, goodsId uint, start, pageSize int) ([]*gen.T, error)

	// SELECT SUM(A.qty*A.mark) sum_qty FROM wms_inventory A
	// WHERE A.status=1 AND A.goods_id=@goodsId AND A.wid=@wid
	// group by A.goods_id,A.wid
	QueryInentoryByGoodsIdAndWid(goodsId, wid uint) (*gen.T, error)

	// SELECT * FROM wms_goods A inner join
	// (SELECT SUM(A.qty*A.mark) sum_qty,A.wid,A.goods_id FROM wms_inventory A
	// {{where}}
	// A.status=1 AND A.goods_id IN (@goodsIdList) AND A.wid IN (@widList)
	// {{end}}
	// group by A.goods_id,A.wid
	// ) B on A.id=B.goods_id
	QueryInentoryByGoodsIdListAndWid(goodsIdList, widList []uint) ([]*gen.T, error)
}
